home *** CD-ROM | disk | FTP | other *** search
- /*
- File: PrintDriverShell.c
-
- Contains: Driver description and export entry points for Printer Class Driver
-
- Version: Neptune 1.0
-
- Copyright: © 1997-1999 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include <MacTypes.h>
- #include <Devices.h>
- #include <DriverServices.h>
- #include <USB.h>
-
- #include "PrinterClassDriver.h"
- #include "PrinterClassVersion.h"
-
- //------------------------------------------------------
- //
- // Protos
- //
- //------------------------------------------------------
- OSStatus printDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc);
- OSStatus printDriverInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
- OSStatus printDriverInitInterface( UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc, USBDeviceDescriptor *deviceDesc, USBDeviceRef device);
- OSStatus printDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc );
- OSStatus printDriverNotifyProc(UInt32 notification, void *pointer, UInt32 refcon);
-
- //------------------------------------------------------
- //
- // This is the driver description structure that the expert looks for first.
- // If it's here, the information within is used to match the driver
- // to the device whose descriptor was passed to the expert.
- // Information in this block is also used by the expert when an
- // entry is created in the Name Registry.
- //
- //------------------------------------------------------
-
- USBDriverDescription TheUSBDriverDescription =
- {
- // Signature info
- kTheUSBDriverDescriptionSignature,
- kInitialUSBDriverDescriptor,
-
- // Device Info
- 0, // vendor = not device specific
- 0, // product = not device specific
- 0, // version of product = not device specific
- 0, // protocol = not device specific
-
- // Interface Info (* I don't think this would always be required...*)
- 0, // Configuration Value
- 0, // Interface Number
- kUSBPrintClass, // Device Class (from USBDeviceDefines.h)
- kUSBPrintSubClass, // Device Subclass
- 0, // Interface Protocol
-
-
- // Driver Info
- "\pUSBPrinterDriver"kPrintStringVersShort,// Driver name for Name Registry
- kUSBPrintClass, // Device Class (from USBDeviceDefines.h)
- kUSBPrintSubClass, // Device Subclass
- kPrintHexMajorVers, kPrintHexMinorVers, kPrintReleaseStage, kPrintNonRelRev, // version of driver
-
- // Driver Loading Info
- 0x00000000 // Flags (currently undefined)
- };
-
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- printDriverValidateHW, // Hardware Validation Procedure
- printDriverInitialize, // Initialization Procedure
- printDriverInitInterface, // Interface Initialization Procedure
- printDriverFinalize, // Finalization Procedure
- printDriverNotifyProc, // Driver Notification Procedure
- };
-
- // Hardware Validation
- // Called upon load by Expert
- OSStatus
- printDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
- {
- device = 0;
- desc = 0;
- // DebugStr("\pPrinter Driver - printDriverValidateHW");
- return (OSStatus)noErr;
- }
-
-
- // Initialization function
- // Called upon load by Expert
- OSStatus
- printDriverInitialize(USBDeviceRef deviceRef, USBDeviceDescriptorPtr pDeviceDesc, UInt32 busPowerAvailable)
- {
- busPowerAvailable = 0;
-
- // DebugStr("\pPrinter Driver - printDriverInitialize");
- USBExpertStatus(deviceRef, "\p"kStrPrinterClass"Driver Initialize", 0);
- PrintDriverEntry(deviceRef, pDeviceDesc, NULL, 0 );
- return (OSStatus)noErr;
- }
-
- // printDriverInitInterface function
- // Called to initialize driver for an individual interface - either by expert or
- // internally by driver
- OSStatus
- printDriverInitInterface(
- UInt32 interfaceNumber,
- USBInterfaceDescriptor *pInterfaceDesc,
- USBDeviceDescriptor *pDeviceDesc,
- USBDeviceRef interfaceRef)
- {
-
- // DebugStr("\pPrinter Driver - printDriverInitInterface");
- USBExpertStatus(interfaceRef, "\p"kStrPrinterClass"Interface Initialize", 0);
- PrintDriverEntry(interfaceRef, pDeviceDesc, pInterfaceDesc, interfaceNumber );
-
- return (OSStatus)noErr;
- }
-
- // Termination function
- // Called by Expert when driver is being shut down
- OSStatus
- printDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc )
- {
- #pragma unused(device)
- #pragma unused(desc)
-
- // DebugStr("\pPrinter Driver - printDriverFinalize");
- return kUSBNoErr;
- }
-
- OSStatus
- printDriverNotifyProc(UInt32 notification, void *pointer, UInt32 refcon)
- {
- #pragma unused(pointer)
- #pragma unused(refcon)
-
- OSStatus err = kUSBNoErr;
-
- // DebugStr("\pPrinter Driver - printDriverNotifyProc");
- switch (notification)
- {
- case kNotifyDriverBeingRemoved:
- err = PrinterRemovalNotification();
- break;
-
- }
- return(err);
- }
-